﻿<controls:ChildWindow
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:module="clr-namespace:Astor.Modules.DataSources"
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
           xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
           xmlns:prism="http://www.codeplex.com/prism" 
           xmlns:debug="clr-namespace:Astor.UI.Framework.Debug;assembly=Astor.UI.Framework"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Astor.Modules.DataSources.Screens.Details.DataSourceDetailsView"
           x:Name="childWindow"
           Width="468" Height="148" Title="{Binding Title}" >
    <controls:ChildWindow.Resources>
        <module:DesignDatalLocator x:Key="designDataLocator" />
    </controls:ChildWindow.Resources>
    
    <i:Interaction.Triggers>
        <prism:InteractionRequestTrigger SourceObject="{Binding CloseRequest}" >
            <prism:InteractionRequestTrigger.Actions>
                <ei:CallMethodAction TargetObject="{Binding ElementName=childWindow}" MethodName="Close" />
            </prism:InteractionRequestTrigger.Actions>   
        </prism:InteractionRequestTrigger>
    </i:Interaction.Triggers>
    
    <Grid x:Name="LayoutRoot" Margin="2" d:DataContext="{Binding Source={StaticResource designDataLocator}, Path=DataSourceDetailsViewModel}">
        <d:Grid.DataContext>
            <Binding Path="DataSourceDetailsViewModel" Source="{StaticResource designDataLocator}" />
        </d:Grid.DataContext>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel DataContext="{Binding DataSource}">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,5,0,0">
                <TextBlock TextWrapping="Wrap" Text="Name" HorizontalAlignment="Left" VerticalAlignment="Center" Width="100"/>
                <TextBox TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" Width="320" Text="{Binding Path=Name, Mode=TwoWay}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,5,0,0">
                <TextBlock TextWrapping="Wrap" Text="Url" HorizontalAlignment="Left" VerticalAlignment="Center" Width="100"/>
                <TextBox TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" Width="320" Text="{Binding Path=Url, Mode=TwoWay}" />
            </StackPanel>
        </StackPanel>

        <Button x:Name="CancelButton" Content="Cancel" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <ei:ChangePropertyAction TargetObject="{Binding}" PropertyName="Confirmed" Value="False"/>
                    <ei:CallMethodAction TargetObject="{Binding ElementName=childWindow}" MethodName="Close" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
        <Button x:Name="OKButton" Content="OK" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" Command="{Binding Path=SubmitCommand}" />
    </Grid>
</controls:ChildWindow>